package com.vecharm.app.bean

import com.google.gson.annotations.SerializedName
import com.ling.sdk.http.ApiResponseBean
import com.ling.sdk.utils.Cache


class SessionBean : ApiResponseBean() {


    @SerializedName("sessionId")
    var sessionId: String? = null

    @SerializedName("signUpUrl")
    var signUpUrl: String? = null

    @SerializedName("interval")
    var interval = 30L

    var isValid = false



    fun save() {
        isValid = true
        sessionBean = this
        Cache.put(TAG, this)
    }

    companion object {

        const val TAG = "session"
        private var sessionBean: SessionBean? = null

        fun getSession(): SessionBean {
            if (sessionBean == null)
                sessionBean = Cache.get(TAG) ?: SessionBean()
            return sessionBean!!
        }

        fun getSessionId() = getSession().sessionId ?: "null"
    }
}